package algorithm;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 给定一个字符串S和一个数量N，求出从字符串S到N的所有字符串。要求字符串中不能出现数字4
 * 例如：
 * S = 00001，N=10
 * Result = 00001, 00002, 00003, 00005, 00006, 00007, 00008, 00009, 00010, 00011
 * User: Asuka
 * Date: 11-3-29
 * Time: 下午12:57
 */
public class Counter {

    public static void main(String[] args) {
        Counter counter = new Counter();
        counter.count("00000001", 10000000);
    }

    public List<String> count(String s, int n) {
        List<String> result = new ArrayList<String>();
        int len = s.length();
        int num = Integer.parseInt(s);
        for (int i = 0; i < n;) {
            String str = String.format("%0" + len + "d", num++);
            if (str.contains("4")) continue;
            i++;
            result.add(str);
        }
        return result;
    }
}
